package com.nuanshui.heatedloan.module.features;

import com.alibaba.dubbo.config.annotation.Reference;
import com.nuanshui.framework.behavior.BehaviorContext;
import com.nuanshui.heatedloan.constant.GlobalParam;
import com.nuanshui.heatedloan.credit.constant.PersonPageStatusConstant;
import com.nuanshui.heatedloan.credit.facade.ExecuteCustomAuthService;
import com.nuanshui.heatedloan.credit.response.PersonPageStatusResponse;
import com.nuanshui.heatedloan.module.constant.FeatureFlagConstant;
import com.nuanshui.heatedloan.module.model.FeatureAttribute;
import com.nuanshui.heatedloan.module.model.FeatureItem;
import com.nuanshui.heatedloan.module.model.ModuleIdConstant;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

import java.util.Iterator;
import java.util.List;


@Service
@FeatureAttribute(moduleId = ModuleIdConstant.MODULE_PERSONSETTING2)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class PersonFeature extends BaseFeature{

	@Reference(url= GlobalParam.CREDIT_DUBBO_SERVER,timeout= GlobalParam.DUBBO_SERVER_TIME_OUT,version = GlobalParam.CREDIT_DUBBO_SERVER_VERSION)
	private ExecuteCustomAuthService executeCustomAuthService;

	@Override
	protected void internalHandleFeature() {
		List<FeatureItem> items = getItem().getInternalData();
		Iterator<FeatureItem> iterator= items.iterator();
		PersonPageStatusResponse personPageStatusResponse=(PersonPageStatusResponse)BehaviorContext.
				getContext().get("personPageStatusResponse");
		while(iterator.hasNext()){
			FeatureItem item=iterator.next();
			//如果是我的认证
            if(FeatureFlagConstant.MYCERTIFCCATIONFLAG.equals(item.getFlagId())&&
					PersonPageStatusConstant.CALCULATIONLIMITED!=personPageStatusResponse.getStatus()){
            	iterator.remove();
			}

		}
		}

	@Override
	public int getModuleId()
	{
		return ModuleIdConstant.MODULE_PERSONSETTING2;
	}
	
}
